home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / languages / dde / _pc / h / coords < prev    next >
Encoding:
Text File  |  1992-02-10  |  6.7 KB  |  200 lines

  1. (*
  2.  * Title:  coords.h
  3.  * Purpose:  Provide common coordinate conversion functions
  4.  *
  5.  *)
  6.  
  7. (*
  8.  * This file contains functions for working in the window coordinate
  9.  * system. Functions are provided to convert between screen and work area
  10.  * coordinates, and perform other simple operations on points, lines, 
  11.  * "boxes".
  12.  * It is conventional to think of the point (0,0) as appearing at the top
  13.  * left-hand corner of a document.
  14.  *
  15.  *)
  16.  
  17. #ifndef __coords_h
  18. #define __coords_h
  19.  
  20. #ifndef __wimp_h
  21. #include "wimp.h"
  22. #endif
  23.  
  24.  
  25. (* Type used for box and scroll position *)
  26.  
  27. type coords_cvtstr_ptr = ^coords_cvtstr;
  28.      coords_cvtstr =
  29.        record
  30.          box : wimp_box;
  31.          scx, scy : integer
  32.        end;
  33.  
  34. (* Type for points *)
  35. type coords_pointstr_ptr = ^coords_pointstr;
  36.      coords_pointstr =
  37.        record
  38.          x, y : integer
  39.        end;
  40.  
  41.  
  42.  
  43. (* ------------------ coords_x_toscreen/coords_y_toscreen ------------------
  44.  * Description:   Convert x/y work area coordinates into x/y screen
  45.  *                coordinates.
  46.  *
  47.  * Parameters:    int x or int y -- x or y coordinate in work area coords
  48.  *                coords_cvtstr *r -- conversion box (screen coords and
  49.  *                                                    scroll offsets).
  50.  * Returns:       x or y screen coordinates.
  51.  * Other Info:    none.
  52.  *
  53.  *)
  54. function coords_x_toscreen(x : integer;
  55.                 r : coords_cvtstr_ptr) : integer; extern;
  56. function coords_y_toscreen(y : integer;
  57.                 r : coords_cvtstr_ptr) : integer; extern;
  58.  
  59.  
  60. (* ----------------- coords_x_toworkarea/coords_y_toworkarea ---------------
  61.  * Description:   Convert x/y screen coordinates into x/y work area
  62.  *                coordinates.
  63.  *
  64.  * Parameters:    int x or int y -- x or y coordinate in screen coords
  65.  *                coords_cvtstr *r -- conversion box (screen coords and
  66.  *                                                    scroll offsets).
  67.  * Returns:       x or y work area coordinates.
  68.  * Other Info:    none.
  69.  *
  70.  *)
  71. function coords_x_toworkarea(x : integer;
  72.                 r : coords_cvtstr_ptr) : integer; extern;
  73. function coords_y_toworkarea(y : integer;
  74.                 r : coords_cvtstr_ptr) : integer; extern;
  75.  
  76.  
  77. (* ------------------------ coords_box_toscreen ----------------------------
  78.  * Description:   Converts a "box" of workarea coordinates into a "box" of
  79.  *                screen coordinates.
  80.  *
  81.  * Parameters:    wimp_box *b -- workarea box to be converted
  82.  *                coords_cvtstr *r -- conversion box (screen coords and
  83.  *                                                    scroll offsets).
  84.  * Returns:       void.
  85.  * Other Info:    "b" is converted "in situ" into screen coordinates (ie. 
  86.  *                its contents change).
  87.  *
  88.  *)
  89. procedure coords_box_toscreen(b : wimp_box_ptr;
  90.                 r : coords_cvtstr_ptr); extern;
  91.  
  92.  
  93. (* ------------------------ coords_box_toworkarea --------------------------
  94.  * Description:   Converts a "box" of screen coordinates into a "box" of
  95.  *                workarea coordinates.
  96.  *
  97.  * Parameters:    wimp_box *b -- screen box to be converted
  98.  *                coords_cvtstr *r -- conversion box (screen coords and
  99.  *                                                    scroll offsets).
  100.  * Returns:       void.
  101.  * Other Info:    "b" is converted "in situ" into workarea coordinates (ie.
  102.  *                its contents are changed).
  103.  *
  104.  *)
  105. procedure coords_box_toworkarea(b : wimp_box_ptr;
  106.                 r : coords_cvtstr_ptr); extern;
  107.  
  108.  
  109. (* ------------------------- coords_point_toscreen -------------------------
  110.  * Description:   Converts a point (x,y) from workarea coordinates to screen
  111.  *                coordinates.
  112.  *
  113.  * Parameters:    coords_pointstr *point -- the point in workarea coordinates
  114.  *                coords_cvtstr *r -- conversion box (screen coords and
  115.  *                                                    scroll offsets).
  116.  * Returns:       void.
  117.  * Other Info:    "point" is converted "in situ" into screen coordinates
  118.  *                (ie. its contents are changed).
  119.  *
  120.  *)
  121. procedure coords_point_toscreen(point : coords_pointstr_ptr;
  122.                 r : coords_cvtstr_ptr); extern;
  123.  
  124.  
  125. (* ------------------------- coords_point_toworkarea -----------------------
  126.  * Description:   Converts a point (x,y) from screen coordinates to workarea
  127.  *                coordinates.
  128.  *
  129.  * Parameters:    coords_pointstr *point -- the point in screen coordinates
  130.  *                coords_cvtstr *r -- conversion box (screen coords and
  131.  *                                                    scroll offsets).
  132.  * Returns:       void.
  133.  * Other Info:    "point" is converted "in situ" into workarea coordinates
  134.  *                (ie. its contents are changed).
  135.  *
  136.  *)
  137. procedure coords_point_toworkarea(point : coords_pointstr_ptr;
  138.                 r : coords_cvtstr_ptr); extern;
  139.  
  140.  
  141. (* -------------------------- coords_withinbox -----------------------------
  142.  * Description:   Informs caller if a point (x,y) lies within a "box".
  143.  *
  144.  * Parameters:    coords_pointstr *point -- the point
  145.  *                wimp_box *box -- the box.
  146.  * Returns:       TRUE if point lies within the box.
  147.  * Other Info:    none.
  148.  *
  149.  *)
  150. function coords_withinbox(point : coords_pointstr_ptr;
  151.                 box : wimp_box_ptr) : boolean; extern;
  152.  
  153.  
  154. (* ------------------------- coords_offsetbox ------------------------------
  155.  * Description:   Offset a "box" by a given "x" and "y" displacement.
  156.  *
  157.  * Parameters:    wimp_box *source -- the box to be moved
  158.  *                int byx -- "x" displacement
  159.  *                int byy -- "y" displacement
  160.  *                wimp_box *result -- box when offset.
  161.  * Returns:       void.
  162.  * Other Info:    "source" and "result" are permitted to point at the same
  163.  *                box.
  164.  *
  165.  *)
  166. procedure coords_offsetbox(source : wimp_box_ptr;
  167.                 byx, byy : integer;
  168.                 result : wimp_box_ptr); extern;
  169.  
  170.  
  171. (* ------------------------- coords_intersects -----------------------------
  172.  * Description:   Informs caller whether a line intersects a given "box"
  173.  *
  174.  * Parameters:    wimp_box *line -- the line
  175.  *                wimp_box *rect -- the box
  176.  *                int widen -- width of line (same units as line and rect).
  177.  * Returns:       TRUE if line intersects box.
  178.  * Other Info:    none.
  179.  *
  180.  *)
  181. function coords_intersects(line : wimp_box_ptr;
  182.                 rect : wimp_box_ptr;
  183.                 widen : integer) : boolean; extern;
  184.  
  185.  
  186. (* ------------------------- coords_boxesoverlap ---------------------------
  187.  * Description:   Informs caller whether two "boxes" cover any common area.
  188.  *
  189.  * Parameters:    wimp_box *box1 -- one box
  190.  *                wimp_box *box2 -- the other box.
  191.  * Returns:       TRUE if boxes overlap.
  192.  * Other Info:    none.
  193.  *
  194.  *)
  195. function coords_boxesoverlap(box1, box2 : wimp_box_ptr) : boolean; extern;
  196.  
  197. #endif
  198.  
  199. (* end coords.h *)
  200.